<template>
  <div>
    <van-cell-group title="基础K线图">
      <div id="myChart" ref="myChart" />
    </van-cell-group>
  </div>
</template>

<script>
import * as echarts from 'echarts';
export default {
  data() {
    return {
      chart: null,
      options: {}
    };
  },
  mounted() {
    this.initOptions();
  },
  methods: {
    initOptions() {
      var chartDom = document.getElementById('myChart');
      var myChart = echarts.init(chartDom);
      var option;
      option = {
        xAxis: {
          data: [
            '2016-03-29',
            '2016-03-30',
            '2016-03-31',
            '2016-04-01',
            '2016-04-04',
            '2016-04-05',
            '2016-04-06',
            '2016-04-07',
            '2016-04-08',
            '2016-04-11',
            '2016-04-12',
            '2016-04-13',
            '2016-04-14',
            '2016-04-15',
            '2016-04-18',
            '2016-04-19',
            '2016-04-20',
            '2016-04-21',
            '2016-04-22',
            '2016-04-25',
            '2016-04-26',
            '2016-04-27',
            '2016-04-28',
            '2016-04-29'
          ]
        },
        yAxis: {},
        series: [
          {
            type: 'candlestick',
            data: [
              [20, 34, 10, 38],
              [12, 35, 30, 50],
              [31, 13, 33, 44],
              [20, 34, 10, 38],
              [40, 35, 14, 50],
              [31, 38, 33, 15],
              [20, 34, 10, 38],
              [40, 35, 30, 50],
              [31, 38, 33, 44],
              [20, 34, 10, 38],
              [40, 35, 30, 50],
              [31, 38, 33, 44],
              [20, 34, 10, 38],
              [40, 35, 30, 50],
              [31, 38, 33, 44],
              [20, 34, 10, 38],
              [40, 35, 30, 50],
              [31, 38, 33, 44],
              [20, 34, 10, 38],
              [40, 35, 30, 50],
              [31, 38, 33, 44],
              [38, 15, 5, 42]
            ]
          }
        ]
      };

      option && myChart.setOption(option);
    }
  }
};
</script>

<style scoped>
#myChart {
  width: 100%;
  height: 280px;
}
</style>
